#!/usr/bin/env python 
# -*- coding:utf-8 -*-
from django import forms
from .models import *


class GlobalSettingForm(forms.ModelForm):
    class Meta:
        model = GlobalSetting
        fields = ('userIsCheckOpen', 'businessIsCheckOpen')


class UserChangeForm(forms.ModelForm):
    class Meta:
        model = UserInfo
        fields = ('account', 'phone', 'province',
                  'city', 'area', 'address')


class UserChangeImgForm(forms.ModelForm):
    class Meta:
        model = UserInfo
        fields = ('imgSrc',)


# 登录表单，继承了 forms.Form 类
class UserLoginForm(forms.Form):
    username = forms.CharField()
    password = forms.CharField()
    captcha = forms.CharField()


class UserRegisterForm(forms.ModelForm):
    captcha = forms.CharField()
    ConfirmPassword = forms.CharField()

    class Meta:
        model = UserInfo
        fields = ('username', 'password', 'email')


class BusinessRegisterForm(forms.ModelForm):
    captcha = forms.CharField()
    ConfirmPassword = forms.CharField()

    class Meta:
        model = BusinessInfo
        fields = ('username', 'password', 'businessType', 'email')

    # def __init__(self, *args, **kwargs):
    #     super().__init__(*args, **kwargs)
    #     self.fields['businessType'].queryset = BusinessType.objects.all().order_by('uploadTime')
